package com.xiyu.service.controller.admin.setting;
import com.xiyu.service.vo.setting.poolSetting.PoolSettingQueryMaxLimitOutput;
import com.xiyu.service.vo.setting.poolSetting.PoolSettingUpdateMaxLimitInput;
import com.xiyu.service.vo.setting.poolSetting.PoolSettingCreateMaxLimitInput;
import com.xiyu.service.vo.setting.poolSetting.PoolSettingGetMaxLimitOutput;
import com.xiyu.service.vo.setting.poolSetting.PoolSettingGetRuleOutput;
import com.xiyu.service.vo.setting.poolSetting.PoolSettingQueryRuleOutput;
import com.xiyu.service.vo.setting.poolSetting.PoolSettingUpdateRuleInput;
import com.xiyu.service.vo.setting.poolSetting.PoolSettingCreateRuleInput;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import jakarta.validation.*;

import java.util.*;

import com.xiyu.service.framework.web.web.core.pojo.PageResult;
import com.xiyu.service.framework.web.web.core.pojo.CommonResult;
import static com.xiyu.service.framework.web.web.core.pojo.CommonResult.success;

import com.xiyu.service.framework.excel.core.util.ExcelUtils;

import com.xiyu.service.framework.operateLog.core.annotations.OperateLog;
import static com.xiyu.service.framework.operateLog.core.enums.OperateTypeEnum.*;

import com.xiyu.service.service.setting.PoolSettingService;

@Tag(name = "公海设置")
@RestController
@RequestMapping("/setting/pool-setting")
@Validated
public class PoolSettingController {

    @Resource
    private PoolSettingService poolSettingService;

    @PostMapping("/create-rule")
    @Operation(summary = "新增公海规则")
    public CommonResult<Long> createRule(@Valid @RequestBody PoolSettingCreateRuleInput inputVO) {
        return success(poolSettingService.createRule(inputVO));
    }

    @PutMapping("/update-rule")
    @Operation(summary = "更新公海规则")
    public CommonResult<Boolean> updateRule(@Valid @RequestBody PoolSettingUpdateRuleInput inputVO) {
        return success(poolSettingService.updateRule(inputVO));
    }

    @DeleteMapping("/delete-rule")
    @Operation(summary = "删除公海规则")
    @Parameter(name = "id", description = "公海规则主键ID", example = "")
    public CommonResult<Boolean> deleteRule(@RequestParam("id") Long id) {
        return success(poolSettingService.deleteRule(id));
    }

    @PostMapping("/query-rule")
    @Operation(summary = "查询公海规则")
    public CommonResult<List<PoolSettingQueryRuleOutput>> queryRule() {
        return success(poolSettingService.queryRule());
    }

    @GetMapping("/get-rule")
    @Operation(summary = "获取单个公海规则")
    @Parameter(name = "id", description = "公海规则主键ID", example = "")
    public CommonResult<PoolSettingGetRuleOutput> getRule(@RequestParam("id") Long id) {
        return success(poolSettingService.getRule(id));
    }

    @GetMapping("/get-max-limit")
    @Operation(summary = "获取最大客户限制")
    @Parameter(name = "id", description = "最大客户限制主键ID", example = "")
    public CommonResult<PoolSettingGetMaxLimitOutput> getMaxLimit(@RequestParam("id") Long id) {
        return success(poolSettingService.getMaxLimit(id));
    }

    @PostMapping("/create-max-limit")
    @Operation(summary = "新增最大客户限制")
    public CommonResult<Long> createMaxLimit(@Valid @RequestBody PoolSettingCreateMaxLimitInput inputVO) {
        return success(poolSettingService.createMaxLimit(inputVO));
    }

    @PutMapping("/update-max-limit")
    @Operation(summary = "更新最大客户限制")
    public CommonResult<Boolean> updateMaxLimit(@Valid @RequestBody PoolSettingUpdateMaxLimitInput inputVO) {
        return success(poolSettingService.updateMaxLimit(inputVO));
    }

    @DeleteMapping("/delete-max-limit")
    @Operation(summary = "删除最大客户限制")
    @Parameter(name = "id", description = "最大客户限制主键ID", example = "")
    public CommonResult<Boolean> deleteMaxLimit(@RequestParam("id") Long id) {
        return success(poolSettingService.deleteMaxLimit(id));
    }

    @GetMapping("/query-max-limit")
    @Operation(summary = "查询最大客户限制")
    public CommonResult<List<PoolSettingQueryMaxLimitOutput>> queryMaxLimit() {
        return success(poolSettingService.queryMaxLimit());
    }

}
